package com.hgw.demo02_LisPrinciple;

/**
 * Data time:2021/12/10 23:54
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class ListkovAfter {
    public static void main(String[] args) {
        classB classB = new classB();
        System.out.println("1+2=" + classB.func2(1, 2));
        System.out.println("1-2=" + classB.func1(1, 2));

    }
}

abstract class base {

}
class classA extends base {
    // 返回两个数相加
    public int func1(int num1, int num2) {
        return num1 + num2;
    }
}
class classB extends base {

    classA a = new classA();

    // 返回两个数相减
    public int func1(int num1, int num2) {
        return num1 - num2;
    }
    // 通过组合的方法调用classA中的方法
    public int func2(int num1, int num2) {
        return this.a.func1(num1,num2);
    }
}